#ifndef DATAWINDOW_H_
#define DATAWINDOW_H_

/* TODO:
 *  - Consider the end case where num_read < num_requested.  The
 *    "extra" data should be zero'd.  NOTE: may be taken care of in
 *    main.c
 */

/*
 * A structure for keeping track of windowed data.
 * Note: "data" is a circular buffer, which means iterating
 *       from p_begin to p_end may be invalid.  Instead,
 *       iterate on the ranges
 *       if p_end > p_begin:
 *           [p_begin, p_end)
 *       else
 *           [p_begin, data + length), [data, p_end)
 * TODO: change to any type of data size instead of just int.
 */
typedef struct _PL_window
{
	unsigned int length;
    unsigned int slide;
    void * p_prev_head;
    void * p_head;
	void * data;
} PL_window;

/*
typedef struct _fragmented_array
{
    unsigned int first_length;
    void * first_piece;

    unsigned int second_length;
    void * second_piece;
} fragmented_array;
*/

extern PL_window * create_window(unsigned int len,  unsigned int slide);
extern void delete_window(PL_window * dw);

extern void slide_window(PL_window * dw);
/*extern fragmented_array get_frag_array(PL_window * dw);*/

extern void * index_from_addr(PL_window * dw, void * addr, unsigned int index);

#endif /*DATAWINDOW_H_*/
